﻿using DevExpress.ExpressApp.Editors;
using DevExpress.ExpressApp.Model;

namespace XAF_React_Sample.Blazor.Server.Editors;

public class ReactSampleEditor : PropertyEditor
{
    public ReactSampleEditor(Type objectType, IModelMemberViewItem model)
        : base(objectType, model)
    {
    }

    protected override object CreateControlCore()
    {
        return new ReactSampleAdapter(new ReactSampleModel
        {
            Value = PropertyValue as string
        });
    }

    protected override object GetControlValueCore()
    {
        return ((ReactSampleAdapter)Control).Model.Value;
    }

    protected override void ReadValueCore()
    {
        ((ReactSampleAdapter)(Control)).Model.Value = PropertyValue as string;
    }
}
